<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.blurry" clearable size="small" placeholder="姓名、身份证、电话" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.psnTypeList" clearable filterable placeholder="人员类别" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in dict.PRIC_NURSCARE_PSN_TYPE"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="1140px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="150px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="护理人员姓名" prop="nurscarePsnName">
                <el-input v-model="form.nurscarePsnName" style="width: 370px;" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="护理人员证件类型" prop="nurscarePsnCertType">
                <el-select v-model="form.nurscarePsnCertType" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.zjlx"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="护理人员证件号码" prop="nurscarePsnCertno">
                <el-input v-model="form.nurscarePsnCertno" style="width: 370px;" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="护理人员性别" prop="nurscarePsnGend">
                <el-select v-model="form.nurscarePsnGend" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.PRIC_GEND"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="人员类别" prop="psnTypeList">
                <el-select v-model="form.psnTypeList" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.PRIC_NURSCARE_PSN_TYPE"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="护理人员电话" prop="nurscareTel">
                <el-input v-model="form.nurscareTel" style="width: 370px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="银行大类">
                <el-input v-model="form.bankMajcls" style="width: 370px;" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="开户行名称">
                <el-input v-model="form.bankName" style="width: 370px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="银行账号">
                <el-input v-model="form.bankacct" style="width: 370px;" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="银行户名">
                <el-input v-model="form.bankAcctname" style="width: 370px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="医保区划" prop="admdvs">
                <el-select v-model="form.admdvs" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.ccstcqh"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="index" label="序号" width="55" />
        <el-table-column prop="nurscarePsnNo" label="护理人员编号" />
        <el-table-column prop="nurscarePsnName" label="护理人员姓名" />
        <el-table-column prop="nurscarePsnCertType" label="护理人员证件类型">
          <template slot-scope="scope">
            {{ dict.label.zjlx[scope.row.nurscarePsnCertType] }}
          </template>
        </el-table-column>
        <el-table-column prop="nurscarePsnCertno" label="护理人员证件号码" width="150px" />
        <el-table-column prop="nurscarePsnGend" label="护理人员性别">
          <template slot-scope="scope">
            {{ dict.label.PRIC_GEND[scope.row.nurscarePsnGend] }}
          </template>
        </el-table-column>
        <el-table-column prop="nurscareTel" label="护理人员电话" />
        <el-table-column prop="psnTypeList" label="人员类别">
          <template slot-scope="scope">
            {{ dict.label.PRIC_NURSCARE_PSN_TYPE[scope.row.psnTypeList] }}
          </template>
        </el-table-column>
        <el-table-column prop="admdvs" label="医保区划">
          <template slot-scope="scope">
            {{ dict.label.ccstcqh[scope.row.admdvs] }}
          </template>
        </el-table-column>
        <el-table-column prop="nurscareOrgNo" label="护理机构编号" />
        <el-table-column prop="nurscarePsnId" label="护理人员ID" />
        <el-table-column v-if="checkPer(['admin','pricPsn:edit','pricPsn:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudPricPsn from '@/api/business/pricPsn'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { pricPsnId: null, uscc: null, nurscarePsnName: null, nurscarePsnCertType: null, nurscarePsnCertno: null, nurscarePsnGend: null, nurscareTel: null, psnTypeList: null, bankMajcls: null, bankName: null, bankId: null, bankacct: null, bankAcctname: null, admdvs: null, psnNurscareRegnIds: null, nurscareOrgNo: null, ywlx: null, lrr: null, lrrxm: null, lrbm: null, lrbmmc: null, lrsj: null, gxr: null, gxrxm: null, gxbm: null, gxbmmc: null, gxsj: null, sfyx: null, bz: null }
export default {
  name: 'PricPsn',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['PRIC_NURSCARE_PSN_TYPE', 'zjlx', 'PRIC_GEND', 'ccstcqh'],
  cruds() {
    return CRUD({ title: '护理员', url: 'api/pricPsn', idField: 'pricPsnId', sort: 'pricPsnId,desc', crudMethod: { ...crudPricPsn }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'pricPsn:add'],
        edit: ['admin', 'pricPsn:edit'],
        del: ['admin', 'pricPsn:del']
      },
      rules: {
        nurscarePsnName: [
          { required: true, message: '护理人员姓名必填', trigger: 'blur' }
        ],
        nurscarePsnCertType: [
          { required: true, message: '护理人员证件类型必填', trigger: 'blur' }
        ],
        nurscarePsnCertno: [
          { required: true, message: '护理人员证件号码必填', trigger: 'blur' }
        ],
        nurscarePsnGend: [
          { required: true, message: '护理人员性别必填', trigger: 'blur' }
        ],
        nurscareTel: [
          { required: true, message: '护理人员电话必填', trigger: 'blur' }
        ],
        psnTypeList: [
          { required: true, message: '人员类别必填', trigger: 'blur' }
        ],
        admdvs: [
          { required: true, message: '医保区划必填', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
